package course.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.PrePersist;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import course.domain.*;

import course.domain.CourseAttribute.Type;

import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
@Entity
public class Course {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	private Date createdAt;
	@ManyToMany(targetEntity=CourseAttribute.class)
	@Size(min=1,message="You must choose at least 1 Course")
	private List<CourseAttribute> CourseAttributes;
	
	@PrePersist
	void createAt() {
		this.createdAt=new Date();
	}
}
